package cn.enilu.flash.warpper;

import cn.enilu.flash.conf.properties.LocalFileProperties;
import cn.enilu.flash.enums.body.*;
import cn.enilu.flash.service.system.impl.ConstantFactory;
import cn.enilu.flash.utils.DateUtil;
import cn.enilu.flash.utils.StringUtils;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/11/04 10:02)
 * @Version v1.0
 * @Modify
 **/
public class CarInfoWarpper extends BaseControllerWarpper  {

    public CarInfoWarpper(List<Map<String, Object>> list) {
        super(list);
    }

    @Override
    public void warpTheMap(Map<String, Object> map) {
        map.put("stateName", State.valueOfCode((Integer) map.get("state")));
        map.put("electricFlagName", YesOrNo.valueOfCode((Integer) map.get("electricFlag")));
        if(StringUtils.isNotNullOrEmpty(map.get("communityId"))) {
            map.put("communityName", ConstantFactory.me().getCommunityNameById((Long) map.get("communityId")));
        }
        if(StringUtils.isNotNullOrEmpty(map.get("custId"))) {
            map.put("custName", ConstantFactory.me().getCustNameById((Long) map.get("custId")));
        }
        if(map.get("registerDate") != null ) {
            map.put("registerDateStr", DateUtil.getDay((Date)map.get("registerDate")));
        }
    }
}
